Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new lint: unnecessary_reserve #14114

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wowinter13
Copy link
Contributor

@wowinter13 wowinter13 commented Jan 30, 2025

resurrection of #10157

fixes #8982

changelog: [unnecessary_reserve]: add new lint unnecessary_reserve

@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 30, 2025
@wowinter13 wowinter13 changed the title new lint: unnecessary_reserve new lint: unnecessary_reserve Jan 30, 2025
@wowinter13
Copy link
Contributor Author

@samueltardieu Samuel, really appreciate your review and points!
Will go through them tomorrow and make sure to apply the lessons

Copy link
Contributor

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include a test (maybe I've missed it) where extend() happens before reserve(), to make sure the lint doesn't trigger?


// do not lint
vec.reserve(1);
vec.extend([1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, error markers are now required in order for tests to pass. If you rebase over master, you will see examples in all the UI test files.

@samueltardieu
Copy link
Contributor

Also, is there any reason why this lint is not under the methods module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary Vec/VecDeque reserve lint
5 participants